package javagame;

import java.awt.*;
import javax.swing.JFrame;

/**
 * @author Sabre Runner
 *
 */
public class Screen
{
	private GraphicsDevice display;
	
	Screen()
	{
		// get our graphics environment
		GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
		// get the default monitor display
		display = environment.getDefaultScreenDevice();
	}
	
	public void setFullScreen(DisplayMode displayMode, JFrame window)
	{
		// no tools and shit
		window.setUndecorated(true);
		// only full screen
		window.setResizable(false);
		// take the window full screen
		display.setFullScreenWindow(window);
		
		if (displayMode != null && display.isDisplayChangeSupported())
		{
			try
			{
				display.setDisplayMode(displayMode);
			}
			catch (Exception exception)
			{
				System.err.println("Display Mode set failed.");
			}
		}
	}

	public Window getFullScreenWindow()
	{
		return display.getFullScreenWindow();
	}

	public void restoreScreen()
	{
		Window window = display.getFullScreenWindow();
		if (window != null)
		{
			window.dispose();
		}
		display.setFullScreenWindow(null);
	}
	
}
